package com.tct.worktimeboard.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tct.worktimeboard.entity.Pdt;
import com.tct.worktimeboard.mapper.PdtMapper;
import com.tct.worktimeboard.service.IPdtService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tct.worktimeboard.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liyongkui
 * @since 2021-02-22
 */
@Service
public class PdtServiceImpl extends ServiceImpl<PdtMapper, Pdt> implements IPdtService {

    @Override
    public JSONObject listPagePdt(Pdt pdt) {
        if(pdt.isPaged()){
            PageHelper.startPage(pdt.getPageNum(),pdt.getPageNum());
        }
        List<Pdt> list = this.list();
        PageInfo<Pdt> info = new PageInfo<>(list);
        Map<String, Object> result = new HashMap<>();
        result.put("total",info.getTotal());
        result.put("rows",list);
        return JsonUtil.toJsonData(result);
    }

}
